<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
		<title>抛出自定义异常</title>
		<script type="text/javascript">
function test(num1,num2){
	try{
		if(arguments.length<2){					//如果参数个数小于2个
			throw new Error("参数个数不够");	//抛出异常
		}
		if(num1/num2=="Infinity"){					//第二个参数为0
			throw new Error("除数不可以为0")	//抛出异常
		}
			
	}catch(exception){
		alert(exception.message);					//在catch区域弹出异常提示信息
	}
}
</script>
</head>
<body>
<script language="javascript">
test(1);									//在body区域调用函数
test(1,0);
</script>
</body>
</html>

